package com.moonLight.weblog.common.domain.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.moonLight.weblog.common.domain.dos.TArticleContentRelDo;

public interface TArticleContentMapper extends BaseMapper<TArticleContentRelDo> {

    /**
     * 根据文章 ID 删除记录content
     * @param articleId
     * @return
     */
    default int deleteByArticleId(Long articleId) {
        return delete(Wrappers.<TArticleContentRelDo>lambdaQuery()
                .eq(TArticleContentRelDo::getArticleId, articleId));
    }
    /**
     * 根据文章 ID 查询文章content
     * @param articleId
     * @return
     */
    default TArticleContentRelDo selectByArticleId(Long articleId) {
        return selectOne(Wrappers.<TArticleContentRelDo>lambdaQuery()
                .eq(TArticleContentRelDo::getArticleId, articleId));
    }

    default int updateByArticleId(TArticleContentRelDo articleContentDO) {
        return update(articleContentDO,
                Wrappers.<TArticleContentRelDo>lambdaQuery()
                        .eq(TArticleContentRelDo::getArticleId, articleContentDO.getArticleId()));
    }
}
